import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class IoNioExample {

    public static void main(String[] args) {
        //read();
        write();
    }

    private static void read()
    {
        try(BufferedInputStream inputStream = new BufferedInputStream(Files.newInputStream(Paths.get("./nio/src/2.txt")))){
            int s = inputStream.available();
            for(int i=0;i<s;i++){
                int c = inputStream.read();
                System.out.print((char) c);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    private static void write()
    {
        try(BufferedOutputStream outputStream = new BufferedOutputStream(Files.newOutputStream(Paths.get("./nio/src/2.txt")))){
            for(int i=0;i<26;i++){
                outputStream.write((byte)('A'+i));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
